Carbon


ThreadSchedulerProcPtr

Header: Threads.h Carbon status: Supported

Defines a pointer to a thread scheduler callback function. Your thread scheduler callback function supplements the Thread Manager default scheduling mechanism.

typedef ThreadID(* ThreadSchedulerProcPtr) (
    SchedulerInfoRecPtr schedulerInfo
);

You would declare your function like this if you were to name it MyThreadSchedulerCallback:

ThreadID MyThreadSchedulerCallback (
    SchedulerInfoRecPtr schedulerInfo
);
schedulerInfo

A pointer to the scheduler information structure that the Thread Manager uses to pass information to MyThreadSchedulerProc.

function result

Δ

DISCUSSION

The MyThreadSchedulerProc function does not supplant the Thread Manager scheduling mechanism but rather works in conjunction with it.

Whenever scheduling occurs, the Thread Manager passes a scheduler information structure to MyThreadSchedulerProc. Among other information, the scheduler information structure contains the thread ID of the current thread and the thread ID of the thread that the application has scheduled to run next.

The MyThreadSchedulerProc function returns to the Thread Manager the thread ID of the thread that it has chosen to schedule and the Thread Manager does the actual scheduling. If MyThreadSchedulerProc decides not to schedule a thread, it returns the constant kNoThreadID and the Thread Manager default scheduling mechanism schedules the next thread.

When the SetThreadScheduler function installs the custom scheduler, it automatically disables scheduling to avoid any reentrancy problems. Therefore, in the custom scheduler, you should make no yield calls or other calls that would cause scheduling to occur.

AVAILABILITY

Supported in Carbon.


© 2000 Apple Computer, Inc. — (Last Updated 3/8/2000)